package cl.blueprintsit.filmdisk.utils;

import cl.blueprintsit.filmdisk.model.Actor;

import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;

/**
 * Created with IntelliJ IDEA.
 * User: Andres
 * Date: 19-10-13
 * Time: 09:47 AM
 * To change this template use File | Settings | File Templates.
 */
public class ActorsManager {

    private static ActorsManager instance;

    private List<Actor> actors;

    private ActorsManager(){
        this.actors = new ArrayList<Actor>();
    }

    public static ActorsManager getInstance() {
        if (ActorsManager.instance == null) {
            ActorsManager.instance = new ActorsManager();
        }

        return ActorsManager.instance;
    }

    public List<Actor> normalizeActors(List<Actor> actorsToNormalize) {
        List<Actor> normalizedActors = new ArrayList<Actor>();
        for (Actor actor : actorsToNormalize) {
            Actor normalizedActor = getNormalizedActor(actor);
            normalizedActors.add(normalizedActor);
        }

        return normalizedActors;
    }

    private Actor getNormalizedActor(Actor actor) {
        if (!actors.contains(actor))
            actors.add(actor);

        return actor;
    }

    public List<Actor> getActors() {
        return actors;
    }
}
